<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
cfc('core')->checklogin();
$return=array();
if($_RQ['op']=='main'){
	$return['set']=$this->plugin_setting('gusetting');
	$return['list'] = array();
	$return['total'] = pdo_getsum('jy_robshop_gu_billp',array('uid'=>$_SESSION['uid']),'paymoney');
	$return['total0'] = pdo_getsum('jy_robshop_gu_billp',array('uid'=>$_SESSION['uid'],'status'=>0),'paymoney');
	$return['total1'] = pdo_getsum('jy_robshop_gu_billp',array('uid'=>$_SESSION['uid'],'status'=>1),'paymoney');
	$return['params']['status'] =$_RQ['status']?:'all';
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('uid'=>$_SESSION['uid']);
	$params['uniacid']=$_SESSION['uniacid'];
	if(isset($_RQ['status']) && $_RQ['status']!='all'){
		$params['status']=trim($_RQ['status']);
		$return['params']['status']=$_RQ['status'];
	}
	if(!empty($_RQ['billid'])){
		$params['billid']=trim($_RQ['billid']);
		$return['params']['billid']=$_RQ['billid'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_robshop_gu_billp',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['member']=cfc('core')->member_show($item['uid']);
			$bill=pdo_get('jy_robshop_gu_bill',array('id'=>$item['billid']));
			$item['billno']=$bill['billno'];
			$item['date']=$bill['year'].'-'.$bill['month'];
			if($bill['week']){
				$item['date'] .='第'.$bill['week'].'周';
			}
			$item['statustitle']=$this->billp_status[$item['status']];
			$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
		}
	}
	$return['list']=$list;
	exi($return);
}